How to add custom template useful for the Unit Test directly in the Xcode Playgroud

Custom template that allows to write unit tests directly in the Xcode Playgroud with nice error/success messages: Screenshot 2021-09-05 at 14 11 30 Screenshot 2021-09-05 at 14 14 28

Installation

Manual

Download and unzip Unit Test.xctemplate.zip Copy Unit Test.xctemplate directory to ~/Library/Developer/Xcode/Templates/File Templates/Playground/ (create the folder if doesn't exits yet)

Bash script

mkdir ./Unit_Test.xctemplate
curl --show-error --location https://github.com/nonameplum/blog/files/7111526/Unit.Test.xctemplate.zip | tar -xf - -C ./Unit_Test.xctemplate
cd ./Unit_Test.xctemplate
mkdir -p ~/Library/Developer/Xcode/Templates/File\ Templates/Playground
cp -R "./Unit Test.xctemplate" ~/Library/Developer/Xcode/Templates/File\ Templates/Playground

Once you restart Xcode you should be able to see the Unit Test template for a new playgroud: Screenshot 2021-09-05 at 14 05 01

Tagged with: